<?php

use yii\db\Migration;

class m190128_144632_cart extends Migration
{
    public function up()
    {
        $this->dropPrimaryKey('Cart', '{{%cart}}');
        $this->addColumn('{{%cart}}', 'id', $this->string(20)->notNull()->comment('购物车 ID')->after('user_id'));
        $this->alterColumn('{{%cart}}', 'user_id', $this->bigInteger()->unsigned()->comment('用户 ID')->after('id'));
        $this->addPrimaryKey('Cart Id', '{{%cart}}', ['id']);
    }

    public function down()
    {
        $this->dropPrimaryKey('Cart Id', '{{%cart}}');
        $this->dropColumn('{{%cart}}', 'id');
        $this->addPrimaryKey('Cart', '{{%cart}}', ['user_id', 'product_id']);
    }
}
